<div class="container" id="content">
<?php

switch ($_SESSION['level']) {
    case -1:
        echo $this->element('parent/failed');
        break;
    case 1:
        echo $this->element('parent/pre_registration');
        break;
    case 2:
        echo $this->element('parent/demographic_info');
        break;
    case 3:
        echo $this->element('parent/yp');
        break;
    case 4:
        echo $this->element('parent/address');
        break;
    case 5:
        echo $this->element('parent/eligibility');
        break;
    case 6:
        echo $this->element('parent/education');
        break;
    case 7:
        echo $this->element('parent/waivers_releases');
        break;
    case 8:
        unset($_SESSION['level']);
        echo $this->element('parent/success');
        break;
    default :
        echo $this->element('parent/pre_registration');
}?>
</div>
<script>
    $(document).ready(function() {
        $('#save-draft').click(function(e) {
            $.ajax({
                url: '<?php echo $this->Html->url(array('controller'=>'users','action'=>'register','parent'=>true)); ?>',
                data: $(this).closest('form').serialize(),
                type: 'POST',
                success: function(data) {
                    console.log(data);
                    $("#success").show().fadeOut(5000); //=== Show Success Message==
                },
                error: function(data) {
                    $("#error").show().fadeOut(5000); //===Show Error Message====
                }
            });
            e.preventDefault(); //=== To Avoid Page Refresh and Fire the Event "Click"===
        });
    });
</script>